package br.com.betioli.jme.games.sokobob;

import br.com.betioli.jme.games.sokobob.i18n.Messages;
import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Command;

/**
 *
 * @author Alexandre Parra Betioli
 */
public class AboutAlert extends Alert {

    private Command backToMenuCommand;

    public AboutAlert() {
        
        super(
                Messages.getMessage("about-title"),
                null,
                null,
                AlertType.INFO);

        backToMenuCommand = new Command(Messages.getMessage("command-back"), Command.BACK, 0);
        addCommand(backToMenuCommand);
        
        setTimeout(FOREVER);
        
        update();
    }
    
    public void update() {
        
        StringBuffer sb = new StringBuffer();
        
        sb.append(SokoBobMIDlet.getInstance().getAppProperty("MIDlet-Name"));
        sb.append("\n");
        sb.append(Messages.getMessage("version"));
        sb.append(SokoBobMIDlet.getInstance().getAppProperty("MIDlet-Version"));
        sb.append("\n");
        sb.append(Messages.getMessage("vendor"));
        sb.append(SokoBobMIDlet.getInstance().getAppProperty("MIDlet-Vendor"));
        sb.append("\n\n");
        sb.append(Messages.getMessage("jar-size"));
        sb.append(SokoBobMIDlet.getInstance().getAppProperty("MIDlet-Jar-Size"));
        sb.append(" Bytes \n");
        sb.append(Messages.getMessage("total-memory"));
        sb.append(Runtime.getRuntime().totalMemory() );
        sb.append(" Bytes \n");
        sb.append(Messages.getMessage("free-memory"));
        sb.append(Runtime.getRuntime().freeMemory());
        sb.append(" Bytes \n");
        sb.append(Messages.getMessage("locale"));
        sb.append(System.getProperty("microedition.locale"));
        
        setString(sb.toString());
    }
}
